<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html" xmlns:constants="http://www.tuanzi.com/constants/tags">

    <div class="ui-g">
        <div class="ui-g-12">
            <h3>
                <b>上线基础信息</b>
            </h3>
        </div>

        <div class="ui-g-2">
            <p:outputLabel for="platform" value="平台"/>
            <strong style="color: red">*</strong>
        </div>
        <div class="ui-g-4">
            <p:selectManyButton id="platform" value="#{loanProductInfoBean.$.selectedPlatforms}"
                                disabled="#{loanProductInfoBean.isView()}">
                <f:selectItem itemLabel="IOS" itemValue="ios"/>
                <f:selectItem itemLabel="ANDROID" itemValue="android"/>
            </p:selectManyButton>
        </div>

        <div class="ui-g-2">
            <p:outputLabel for="redirectType" value="跳转类型"/>
            <strong style="color: red">*</strong>
        </div>

        <div class="ui-g-4">
            <p:selectOneMenu id="redirectType" value="#{loanProductInfoBean.$.redirectType}" disabled="#{loanProductInfoBean.isView()}">
                <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                <f:selectItem itemLabel="详情页" itemValue="1"/>
                <f:selectItem itemLabel="API资料页" itemValue="2"/>
                <f:selectItem itemLabel="结果页" itemValue="3"/>
                <f:selectItem itemLabel="合作方H5页" itemValue="4"/>
                <f:selectItem itemLabel="车主信用卡" itemValue="5"/>
            </p:selectOneMenu>
        </div>

        <div class="ui-g-2">
            <p:outputLabel for="openType" value="打开方式"/>
            <strong style="color: red">*</strong>
        </div>
        <div class="ui-g-4">
            <p:selectOneButton id="openType" disabled="#{loanProductInfoBean.isView()}"
                               value="#{loanProductInfoBean.$.openType}">
                <f:selectItem itemLabel="站内跳转" itemValue="0" noSelectionOption="true"/>
                <f:selectItem itemLabel="浏览器打开" itemValue="1"/>
            </p:selectOneButton>
        </div>

        <div class="ui-g-2">
            <p:outputLabel for="isAlternate" value="推荐池类型"/>
            <strong style="color: red">*</strong>
        </div>
        <div class="ui-g-4">
            <p:selectOneMenu id="isAlternate"
                             value="#{loanProductInfoBean.$.recommendType}" filter="true"
                             filterMatchMode="contains" disabled="#{loanProductInfoBean.isView()}">

                <f:selectItems value="#{loanProductInfoBean.dictionaries[DictionaryCode.RECOMMEND_POOL_TYPE]}"
                               var="dic"
                               itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
            </p:selectOneMenu>
        </div>

        <div class="ui-g-2">
            <p:outputLabel for="parentProd" value="所属大产品"/>
            <strong style="color: red">*</strong>
        </div>
        <div class="ui-g-10">
            <p:selectOneMenu id="parentProd"
                             value="#{loanProductInfoBean.$.parentProd}" filter="true"
                             filterMatchMode="contains" disabled="#{loanProductInfoBean.isView()}">
                <f:selectItem itemLabel="- 请选择 -" itemValue=""
                              noSelectionOption="true"/>
                <f:selectItems value="#{loanProductInfoBean.dictionaries[DictionaryCode.LARGE_COMMON_PRODUCT]}"
                               var="dic"
                               itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                <p:ajax event="change" process="@this" update="prd,channel" listener="#{loanProductInfoBean.onSelectParentProd}"/>
            </p:selectOneMenu>
        </div>

        <div class="ui-g-12">
            <h3><b>控量信息</b></h3>
        </div>
        <div class="ui-g-2">
            <p:outputLabel for="dailyClickUvLimitation" value="总控量"/><strong style="color: red">*</strong>
        </div>
        <div class="ui-g-4">
            <p:inputText id="dailyClickUvLimitation" value="#{loanProductInfoBean.$.dayLimitClickUv}"
                         disabled="#{loanProductInfoBean.isView()}">
                <p:keyFilter regEx="/[\d]/"/>
            </p:inputText>
        </div>

        <div class="ui-g-2">
            <p:outputLabel for="everyDayOnlineTime" value="上线下线时间"/>
        </div>
        <div class="ui-g-4">
            <p:calendar id="everyDayOnlineTime" value="#{loanProductInfoBean.$.everyDayOnlineTime}" styleClass="autoWidthCalendar"
                        locale="#{constants:get('LOCALE')}"
                        timeZone="#{constants:get('TIME_ZONE')}"
                        pattern="HH:mm"
                        timeOnly="true" disabled="#{loanProductInfoBean.isView()}"/>

            -
            <p:calendar id="everyDayOfflineTime" value="#{loanProductInfoBean.$.everyDayOfflineTime}" styleClass="autoWidthCalendar"
                        locale="#{constants:get('LOCALE')}"
                        timeZone="#{constants:get('TIME_ZONE')}"
                        pattern="HH:mm"
                        timeOnly="true" disabled="#{loanProductInfoBean.isView()}"/>
        </div>
        <div class="ui-g-2"><p:outputLabel value="预付下线"/></div>
        <div class="ui-g-4">
            <p:inputSwitch onLabel="开启" id="prepayOffLine"
                           offLabel="关闭"
                           value="${loanProductInfoBean.$.prepayOffLine}"
                           disabled="#{loanProductInfoBean.isView()}">
                <p:ajax event="change"
                        listener="#{loanProductInfoBean.onChangePrepaySwitch}"
                        process="@this"/>
            </p:inputSwitch>
        </div>

        <div class="ui-g-12">
            <h3><b>广告位控量</b></h3>
        </div>
        <div class="ui-g-1">
            <p:outputLabel for="listLimit" value="列表"/>
        </div>
        <div class="ui-g-3">
            <div class="input-group">
                <p:inputNumber id="listLimit" value="#{loanProductInfoBean.$.productJoinedLimit.listLimit}"
                               decimalPlaces="0"
                               disabled="#{loanProductInfoBean.isView()}"/>
                <span class="input-group-addon">%</span>
            </div>
        </div>

        <div class="ui-g-1">
            <p:outputLabel for="recommendLimit" value="推荐位"/>
        </div>
        <div class="ui-g-3">
            <div class="input-group">
                <p:inputNumber id="recommendLimit" value="#{loanProductInfoBean.$.productJoinedLimit.recommendLimit}"
                               decimalPlaces="0"
                               disabled="#{loanProductInfoBean.isView()}"/>
                <span class="input-group-addon">%</span>
            </div>
        </div>

        <div class="ui-g-1">
            <p:outputLabel for="topicLimit" value="专题"/>
        </div>
        <div class="ui-g-3">
            <div class="input-group">
                <p:inputNumber id="topicLimit" value="#{loanProductInfoBean.$.productJoinedLimit.topicLimit}"
                               decimalPlaces="0"
                               disabled="#{loanProductInfoBean.isView()}"/>
                <span class="input-group-addon">%</span>
            </div>
        </div>

        <div class="ui-g-12">
            <h3>
                上线产品
                <p:commandButton value="全选"
                                 actionListener="#{loanProductInfoBean.onSelectAllProduct()}"
                                 update="prd"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
            </h3>
        </div>

        <div class="ui-g-12">
            <p:selectManyButton id="prd" disabled="#{loanProductInfoBean.isView()}"
                                value="#{loanProductInfoBean.$.selectedOnlineProducts}">
                <f:selectItems
                        value="#{loanProductInfoBean.commProductIds}"
                        var="product"
                        itemLabel="#{product.name}(#{product.productId})" itemValue="#{product.productId}"/>
            </p:selectManyButton>
        </div>

        <div class="ui-g-12">
            <h3>
                用户类型
                <p:commandButton value="全选"
                                 actionListener="#{loanProductInfoBean.onSelectedAllApiFicoTag()}"
                                 update="userTag"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
            </h3>
        </div>
        <div class="ui-g-12">
            <p:selectManyButton id="userTag" disabled="#{loanProductInfoBean.isView()}"
                                value="#{loanProductInfoBean.$.selectedApiFicoTags}">
                <f:selectItems
                        value="#{loanProductInfoBean.userTags}"
                        var="userTag"
                        itemLabel="#{userTag.label}" itemValue="#{userTag.value}"/>
            </p:selectManyButton>
        </div>


        <div class="ui-g-12">
            <h3><b>其他限制</b></h3>
        </div>
        <div class="ui-g-2">
            <p:outputLabel for="minVersion" value="最小版本"/>
        </div>
        <div class="ui-g-4">
            <div class="input-group">
                <p:inputNumber id="minVersion" value="#{loanProductInfoBean.$.onlineRule.minVersion}"
                               decimalPlaces="0"
                               disabled="#{loanProductInfoBean.isView()}"/>
            </div>
        </div>

        <div class="ui-g-2">
            <p:outputLabel for="maxVersion" value="最大版本"/>
        </div>
        <div class="ui-g-4">
            <div class="input-group">
                <p:inputNumber id="maxVersion" value="#{loanProductInfoBean.$.onlineRule.maxVersion}"
                               decimalPlaces="0"
                               disabled="#{loanProductInfoBean.isView()}"/>
            </div>
        </div>

        <div class="ui-g-2">
            <p:outputLabel for="device" value="设备限制"/><strong style="color: red">*</strong>
        </div>
        <div class="ui-g-4">
            <p:selectManyButton id="device" value="#{loanProductInfoBean.$.onlineRule.device}"
                                disabled="#{loanProductInfoBean.isView()}">
                <f:selectItem itemLabel="新用户" itemValue="1"/>
                <f:selectItem itemLabel="老用户" itemValue="0"/>
            </p:selectManyButton>
        </div>


        <div class="ui-g-12">
            <h3>
                <b>剔除渠道</b>
                <p:commandButton value="全选"
                                 actionListener="#{loanProductInfoBean.onSelectAllExcludeChannel()}"
                                 update="channel"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
                <p:commandButton value="信息流"
                                 actionListener="#{loanProductInfoBean.onSelectChannelGroupExcludeChannel(0)}"
                                 update="channel"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
                <p:commandButton value="同行"
                                 actionListener="#{loanProductInfoBean.onSelectChannelGroupExcludeChannel(1)}"
                                 update="channel"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
                <p:commandButton value="应用市场"
                                 actionListener="#{loanProductInfoBean.onSelectChannelGroupExcludeChannel(2)}"
                                 update="channel"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
                <p:commandButton value="短信"
                                 actionListener="#{loanProductInfoBean.onSelectChannelGroupExcludeChannel(3)}"
                                 update="channel"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
                <p:commandButton value="其他"
                                 actionListener="#{loanProductInfoBean.onSelectChannelGroupExcludeChannel(4)}"
                                 update="channel"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
                <p:commandButton value="公众号"
                                 actionListener="#{loanProductInfoBean.onSelectChannelGroupExcludeChannel(5)}"
                                 update="channel"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
                <p:commandButton value="运营"
                                 actionListener="#{loanProductInfoBean.onSelectChannelGroupExcludeChannel(6)}"
                                 update="channel"
                                 process="@this"
                                 disabled="#{loanProductInfoBean.isView()}"/>
            </h3>
        </div>

        <div class="ui-g-12">
            <p:selectManyButton id="channel" disabled="#{loanProductInfoBean.isView()}"
                                value="#{loanProductInfoBean.$.selectedExcludeChannels}">
                <f:selectItems
                        value="#{loanProductInfoBean.commProductChannels}"
                        var="channel"
                        itemLabel="#{channel.channelName}(#{channel.channelCode})"
                        itemValue="#{channel.channelCode}"/>
            </p:selectManyButton>
        </div>
    </div>
</ui:composition>